<?php
/**
 * Class for profile log.
 * 
 * LICENSE:
 * 
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with This library. If not, see <{@link http://www.gnu.org/licenses/}>.
 *
 * @link http://code.google.com/p/phpstartapp/
 * @author Bojan Mauser <bmauser@gmail.com>
 * @copyright Bojan Mauser 2009
 * @package psa
 * @version $Id: Psa_Logger.class.php 153 2008-11-27 01:05:57Z bmauser $
 * @ignore 
 */


/**
 * This class handles profile logging.
 * @ignore 
 */
class Psa_Profile_Logger extends Psa_Logger{

	
	/**
	 * returns Psa_Profile_Logger instance
	 */
	public static function get_instance($classname = __CLASS__){
		return parent::get_instance($classname);
	}
	
	
	/**
	 * Calls parent log method with 'psa_profile' as default storage
	 */
	public function log($log_data,$log_storage = 'psa_profile'){
		parent::log($log_data,$log_storage);
	}

		
	/**
	 * returns database query
	 */
	protected function format_database_log_query($log_storage){
		// global config array
		global $PSA_CFG;
		
		// log query. Should be formated for prepared query.
		return "INSERT INTO " . $PSA_CFG['logging']['storage'][$log_storage]['target'] . " (method, total_time, method_arguments, client_ip, log_time, request_id) VALUES (?,?,?,?,NOW(),?)";	
	}

	
	/**
	 * returns parameters for prepared query
	 */
	protected function format_database_log_query_params($log_data){
		
		// parameters for prepared log query
		return array(
			$log_data['method'],
			$log_data['total_time'],
			$log_data['method_arguments'],
			@$_SERVER["REMOTE_ADDR"],
			$log_data["request_id"]
		);
	}
}

